<?php
/**
 * 任务完成日志
 * author itholiday@126.com
 */
global $_W, $_GPC;
load()->func('tpl');
$html_title = $_W['current_module']['title'];
$op = !empty($_GPC['op']) ? $_GPC['op'] : 'list';
//$op =$_GPC['op'];
//页面显示条数
$pagesize = 20;
$page = max(1, $_GPC['page']);
$start = ($page - 1) * $pagesize;

$where = "A.id > 0";

$keyword = isset($_GPC['keyword']) && !empty($_GPC['keyword']) ? input('keyword') : '';
$start_time = isset($_GPC['start_time']) && !empty($_GPC['start_time']) ? strtotime($_GPC['start_time']) : '';
$end_time = isset($_GPC['end_time']) && !empty($_GPC['end_time']) ? strtotime($_GPC['end_time']) : '';
$logtype = isset($_GPC['logtype']) ? input('logtype') : '';

if (!empty($logtype)){
    $where .= " and A.type='$logtype' ";
}

if (!empty($keyword)){
    $where .= " and (A.user_id='$keyword' or B.mobile='$keyword' or A.taskid='$keyword'  or B.truename like '%$keyword%') ";
}

if (!empty($start_time) && !empty($end_time)){
    $where .= " and A.create_time>=$start_time and A.create_time<=$end_time ";
} else {
    if (!empty($start_time)){
        $where .= " and A.create_time >= $start_time ";
    }
    if (!empty($end_time)){
        $where .= " and A.create_time <= $end_time ";
    }
}

if ($op == "list" || $op == ""){
    $pagediv = "list";
    $total = pdo_fetchcolumn('SELECT COUNT(*) AS `number` FROM ' . tablename('yq_haircircle_user_task_log') . 'A left join ims_yq_haircircle_users B on A.user_id=B.id WHERE ' . $where);
    $pager = getPageHTML($total,$page,$pagesize);
    $sql = " select A.* from ims_yq_haircircle_user_task_log A left join ims_yq_haircircle_users B on A.user_id=B.id where $where order by A.id desc limit $start,$pagesize ";
    $list = pdo_fetchall($sql);
    include $this->template('web/user_task_log');
    exit;
}



